package com.jbit.controller;

import com.jbit.dto.DmItem;
import com.jbit.dto.DmScheduler;
import com.jbit.dto.DmSchedulerSeatPrice;
import com.jbit.service.DmItemCommentService;
import com.jbit.service.DmItemService;
import com.jbit.service.DmScheduleSeatPriceService;
import com.jbit.service.DmSchedulerService;
import com.jbit.utils.ResponseEntity;
import javafx.geometry.Pos;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/item/api/p")
public class ItemController {
    @Resource
    private DmItemService dmItemService;
    @Resource
    private DmSchedulerService dmSchedulerService;
    @Resource
    private DmScheduleSeatPriceService dmScheduleSeatPriceService;
    @Resource
    private DmItemCommentService dmItemCommentService;
    @PostMapping("/queryItemLike")
    public ResponseEntity queryItemLike(@RequestBody Map<String, Object> map) {
        return ResponseEntity.sendSuccess(dmItemService.queryItemLike(map));
    }

    @PostMapping("/queryItemDetail")
    public ResponseEntity queryItemDetail(@RequestBody DmScheduler dmScheduler){
        return ResponseEntity.sendSuccess(dmItemService.queryById(dmScheduler.getId()));
    }
    @PostMapping("/queryItemScheduler")
    public ResponseEntity queryItemScheduler(@RequestBody DmScheduler dmScheduler){
        return ResponseEntity.sendSuccess(dmSchedulerService.queryByItemId(dmScheduler.getItemId()));
    }
    @PostMapping("/queryItemPrice")
    public ResponseEntity queryItemPrice(@RequestBody DmSchedulerSeatPrice dmSchedulerSeatPrice){
        return ResponseEntity.sendSuccess(dmScheduleSeatPriceService.querySeatPriceByScheduleId(dmSchedulerSeatPrice.getScheduleId()));
    }
    @PostMapping("/queryItemComment")
    public ResponseEntity queryItemComment(@RequestBody DmScheduler dmScheduler){
        DmItem dmItem = dmItemService.queryById(dmScheduler.getId());

        return ResponseEntity.sendSuccess(dmItemCommentService.queryByItemId(dmItem.getId()));
    }
}
